﻿using pbvs.Data.Repositories.Interfaces;
using System.Linq;
using pbvs.Models;

namespace pbvs.Data.Repositories
{
	public class DefaultsRepository : IDefaultsRepository
	{
		private readonly PbvsContext _db;

		public DefaultsRepository(PbvsContext db)
		{
			_db = db;
		}

		public IQueryable<Default> Defaults
		{
			get { return _db.Defaults; }
		}

		public void Add(Default def)
		{
			_db.Defaults.Add(def);
		}

		public void Update(Default def)
		{
			Default siteDefault = _db.Defaults.Find(def.Id);
			siteDefault.Name = def.Name;
			siteDefault.Value = def.Value;
		}

		public int Save()
		{
			return _db.SaveChanges();
		}
	}
}